

from common import market_to_str
from x_com import source_api
import x_com_lib

def subscribe_rt_data_to_topic(conn_id: int, param: source_api.SubscribeRTDataRequest) -> x_com_lib.PySubscribeTopicInfo:
    
    
    subscibe_info = x_com_lib.PySubscribeTopicInfo()
    market_str = market_to_str(param.market)
    subscibe_info.topic = "RtTickData"
    
    tags = []
    for code in param.code:
      tags.append(f"{market_str}.{code}")

    subscibe_info.conn_id = conn_id
    subscibe_info.tag = tags
    return subscibe_info

